package com.c1802.action;

import com.c1802.dao.CommentDao;
import com.c1802.dao.Impl.CommentDaiImpl;
import com.c1802.entity.Comment_hf;
import com.c1802.entity.Leave_Word;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.logging.log4j.core.jackson.Log4jYamlObjectMapper;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;

public class HFAction extends ActionSupport {
    String user_name;
    String hf;
    int leave_id;
    String user_img;

    @Override
    public String execute() throws Exception {
        HttpServletRequest request= ServletActionContext.getRequest();
        System.out.println(user_name+"--"+user_img+"--"+leave_id);
        Comment_hf comment_hf=new Comment_hf(leave_id,user_name,user_img);
        request.getSession().setAttribute("comment_hf",comment_hf);
        return SUCCESS;
    }

    public String add() throws Exception {
        System.out.println(user_name+"--"+user_img+"--"+leave_id+"--"+hf);
        CommentDao dao=new CommentDaiImpl();
        int num=dao.add(user_name,user_img,hf,leave_id);
        if(num>0)
        {
            return SUCCESS;
        }else {
            return ERROR;
        }

    }


    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getHf() {
        return hf;
    }

    public void setHf(String hf) {
        this.hf = hf;
    }

    public int getLeave_id() {
        return leave_id;
    }

    public void setLeave_id(int leave_id) {
        this.leave_id = leave_id;
    }

    public String getUser_img() {
        return user_img;
    }

    public void setUser_img(String user_img) {
        this.user_img = user_img;
    }
}
